/********************************Copyright (c)**********************************\
**
 **                   (c) Copyright 2023, Main, China, QD.
 **                           All Rights Reserved
 **
 **                                By(wo4fisher)
 **                           http://www.wo4fisher.com
 **
 **----------------------------------文件信息------------------------------------
 ** 文件名称: myiic.h
 ** 创建人员: wht
 ** 创建日期: 2023-12-19
 ** 文档描述:
 **
 **----------------------------------版本信息------------------------------------
 ** 版本代号: V0.1
 ** 版本说明: 初始版本
 **
 **------------------------------------------------------------------------------
 \********************************End of Head************************************/

#ifndef __MYIIC_H_
#define __MYIIC_H_
#include "ch32v20x.h"

#define IIC_SCL_PIN GPIO_Pin_15
#define IIC_SCL_PORT GPIOB

#define IIC_SDA_PIN GPIO_Pin_14
#define IIC_SDA_PORT GPIOB

#define IIC_INT_PIN GPIO_Pin_13
#define IIC_INT_PORT GPIOB

typedef enum {
    NACK = 0, ACK = 1
} ACK_STATUS;

#define IIC_SDA_H()  GPIO_WriteBit(IIC_SDA_PORT,IIC_SDA_PIN,Bit_SET)
#define IIC_SDA_L()  GPIO_WriteBit(IIC_SDA_PORT,IIC_SDA_PIN,Bit_RESET)
#define IIC_SCL_H()  GPIO_WriteBit(IIC_SCL_PORT,IIC_SCL_PIN,Bit_SET)
#define IIC_SCL_L()  GPIO_WriteBit(IIC_SCL_PORT,IIC_SCL_PIN,Bit_RESET)

void Soft_IIC_Init(void);
uint8_t Soft_IIC_Mem_Read(uint8_t devAddr, uint8_t memAddr, uint8_t * pData,
        uint8_t len);
uint8_t Soft_IIC_Mem_Write(uint8_t devAddr, uint8_t memAddr, uint8_t * pData,
        uint8_t len);

#endif

/********************************End of File************************************/
